Switching images depending on light/dark mode
Switch your screen between light and dark mode and watch this content automatically update!
One nice way to use this in Julia is to generate two plots in two color themes, and use this to make sure that the right one is displayed to the reader.
👀 Reading hidden code
🌝
🌚
👀 Reading hidden code
You are in light mode!
You are in dark mode!
👀 Reading hidden code
"☀️"
"🍦"
"⭐️"
123
"🛰️"
"💂"
"🎱"
👀 Reading hidden code
Test images
👀 Reading hidden code
big (generic function with 1 method)
big(x) = @htl """
<span style="font-size: 10rem;">$x</span>
"""
👀 Reading hidden code
gerhARD
big("gerhARD")
👀 Reading hidden code
🌚
dark_plot = big("🌚")
👀 Reading hidden code
🌝
light_plot = big("🌝")
👀 Reading hidden code
How it works
👀 Reading hidden code
using HypertextLiteral
👀 Reading hidden code
using PlutoUI
👀 Reading hidden code
lightdark (generic function with 1 method)
lightdark(light, dark) = PlutoUI.ExperimentalLayout.Div([
@htl("""
<style>
.plutoui-only-when-light {
display: unset;
}
.plutoui-only-when-dark {
display: none;
}
@media (prefers-color-scheme: dark) {
.plutoui-only-when-light {
display: none;
}
.plutoui-only-when-dark {
display: unset;
}
}
</style>
"""),
PlutoUI.ExperimentalLayout.Div([light]; class="plutoui-only-when-light"),
PlutoUI.ExperimentalLayout.Div([dark]; class="plutoui-only-when-dark"),
])
👀 Reading hidden code